package com.clt.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.clt.web.service.IWxMesgService;

/**
 * 消息回复controller
 * 
 * @author hp
 * 
 */
@Controller
@RequestMapping("/weixin/mesg")
public class WeixinMesgController {

	@Autowired
	private IWxMesgService wxMesgService;

	/**
	 * 页面先传回openid
	 * 
	 * @param openid
	 * @param req
	 * @param resp
	 * @return
	 */
	@RequestMapping("/sendmesg")
	public String sendtext(String openid, HttpServletRequest req, HttpServletResponse resp) {
		req.setAttribute("openid", openid);
		return "mobile/mesg";
	}

	/**
	 * 发送文本信息
	 */
	@RequestMapping("/dosendmesg")
	public String sendmesg(String openId, String text, HttpServletRequest req, HttpServletResponse resp) {
		String result = wxMesgService.sendTextMesg(openId, text);
		req.setAttribute("result", result);
		return "sendsuccess";
	}
}
